﻿using AuSys.Repos;
using AuSys.Test.TestSupport.Fakes;

namespace AuSys.Test.Repos.App.TestSupport
{
    public class MockRepoCache(
        FakeDataContext context
        ) : RepoCache<FakeEntity, FakeEntityCache>(context)
    {
        public int ProjectedTimes { get; private set;}
        protected override IQueryable<FakeEntityCache> DbProjectToCache(
            IQueryable<FakeEntity> source)
        {
            ProjectedTimes++;
            return source.Select(x => new FakeEntityCache(x.Id, x.Name, x.ParentId));
        }

        public int PublicAdd(FakeEntity item, bool saveChanges = true)
            => base.Add(item, saveChanges);
        public List<FakeEntityCache> PublicCacheSearch(
            Predicate<FakeEntityCache> predicate)
            => CacheSearchRange(predicate);
        public void PublicCacheReset() => CacheReset();
    }
}
